/*
 * @Author: your name
 * @Date: 2021-05-19 22:20:10
 * @LastEditTime: 2021-05-19 22:31:03
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \learn_T\src\main.rs
 */

fn largest_i32(list: &[i32]) -> i32 {
    let mut largest = list[0];
    for &item in list.iter() {
        if item > largest {
            largest = item;
        }
    }
    largest
}

fn largest_char(list: &[char]) -> char {
    let mut largest = list[0];
    for &item in list.iter() {
        if item > largest {
            largest = item;
        }
    }
    largest
}

//-----------------使用泛型-----------------------//
fn largest<T: PartialOrd + Copy> (list: &[T]) -> T {
    let mut larger = list[0];
    for &item in list.iter() {
        if item > larger {
            larger = item;
        }
    }
    larger
}
fn main() {
    let number_list = vec![1,2,25,62,15,100,10];
    let max_number = largest_i32(&number_list);
    println!("max number is {}", max_number);
    println!("Hello, world!");
}
